::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::Start this batch file, Set which directories & programs we will be using.
::Delete any previously generated files before we begin.
::BuildPath is where the generated files will be created.
@ECHO OFF
CLS
SET BuildPath=D:\projects\OpenProject.Net\DataObjects
SET Sonic=D:\projects\sonic.exe
SET Generate=generate /override /spStartsWith SP_ /viewStartsWith View /out %BuildPath% /lang c#
SET ODS=generateODS /override /out %BuildPath% /lang c#
SET VIEWS=generateviews /override /out %BuildPath% /lang c# /viewStartsWith View
IF EXIST %BuildPath% RD %BuildPath% /S /Q
IF EXIST %BuildPath% GOTO FailedDelete
MD %BuildPath%
GOTO BuildProviderOptions


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::See if the user specified a valid option from the command line, if so
::Setup the connection string for the database, if not display warning message.
:BuildProviderOptions
IF [%1]==[TEST1] GOTO BuildTest1
IF [%1]==[TEST2] GOTO BuildTest2
GOTO MissingParam


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:BuildTest1
SET DATABASE=/server indigo\sqlexpress /db OpenProject /generatedNamespace OpenProject.DataObjects
GOTO GenerateDatabase


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:BuildTest2
:SET DATABASE=/server localhost /db test2 /userid Joe /password Blogs /generatedNamespace Test2
:GOTO GenerateDatabase


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::Start generating your DAL files
:GenerateDatabase
CLS
ECHO Generate using connection string : %DATABASE%
ECHO.
%Sonic% %Generate% %DATABASE%
%Sonic% %ODS% %DATABASE%
%Sonic% %VIEWS% %DATABASE%
GOTO End


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::Display help menu when a user doesn't enter a valid option
:MissingParam
ECHO SubSonic Builder
ECHO --------------------------------------------------
ECHO.
ECHO Usage:
ECHO.
ECHO    SubSonicBuilder {BuildProvider}
ECHO.
ECHO Valid BuildProvider Selections:
ECHO.
ECHO    TEST1
ECHO    TEST2
GOTO End


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:FailedDelete
CLS
ECHO SubSonic Builder
ECHO --------------------------------------------------
ECHO Error:
ECHO.
ECHO The BuildPath directory could not be deleted, one or more files may be open in another application.
GOTO End

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::End of the batch file
:End
ECHO.
ECHO Sub Sonic Builder... Done.
ECHO.